﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sylvain.Manager;
using Sylvain.Model;


public partial class Contracts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ISylvainManager objManager = new SylvainManager();
            //int pageId = objManager.GetPageId("contracts");
            //string pageContent = objManager.GetPageContent(pageId);
            //if (pageContent.Length > 0)
            //{

            //    mainDiv.InnerHtml = pageContent;
            //}

            List<Contract> listContracts = new List<Contract>();
            listContracts = objManager.GetAllContracts();
            int num=1;
            foreach (Contract contract in listContracts)
            {
                contract.Id = num;
                num++;
            }
            int count = 0;
            if (listContracts.Count % 2 == 0)
            {
                count = listContracts.Count / 2;
            }
            else { count = (listContracts.Count / 2)+1; }
            dlContracts1.DataSource = listContracts.Take(count);
            dlContracts1.DataBind();
            dlContracts2.DataSource = listContracts.Skip(count);
            dlContracts2.DataBind();
        }
    }
}